1. Field
The following description relates to a method and apparatus for processing a shuffle instruction. The following description also relates to a method and apparatus for processing an N-way single instruction multiple data (SIMD) shuffle instruction.
2. Description of Related Art
A single instruction multiple data (SIMD) instruction is one way to enhance data level parallelism.
An N-way SIMD shuffle instruction includes two input operands. A first operand of the two input operands includes data elements, and a second operand includes selection bits.
The data elements of the first operand are selected by the corresponding selection bits of the second operand. The data elements may correspond to the selection bits, based on a sequential order. For example, a first data element may correspond to a first selection bit.
The data elements of the first operand may be data targeted for shuffling. The selection bits of the second operand may be data indicating a shuffling method.
When the second operand includes “K” number of bits having a “1” value and includes “N−K” number of bits having a “0” value, a “K” number of corresponding data elements of the first operand is associated with the bits having the “1” value, and “N−K” number of corresponding data elements of the first operand is associated with the bits having the “0” value.
The “K” number of data elements corresponding to the “K” number of bits of which the value of the second operand is “1” from among the plurality of data elements of the first operand are determined to be the selected data elements. Thus, a set of selected data elements is determined from the set of data elements in the first operand based on using the corresponding bits as flags. A first occurring “K” number of data elements from among output data elements output as a result of shuffling includes the “K” number of selected data elements, and a subsequently occurring “N−K” number of data elements of the output data elements includes unselected “N−K” number of data elements of the first operand.
A sequential order of the “K” number of selected data elements may be maintained in the output data elements of shuffling. Also, a sequential order of the “N−K” number of unselected data elements may be maintained in the output data elements of shuffling. For example, a shuffle instruction refers to disposing a portion of data elements selected by a control bit from among a plurality of data elements, preceding a remainder of the plurality of data elements. Said differently, a shuffle instruction extracts a subset of selected data elements in order from a set of data elements, and then appends the remaining elements in order following the selected data elements.